1. Field of the Invention
The present disclosure relates generally to an improved data processing system and in particular to a method and apparatus for processing data. Still more particularly, the present disclosure relates to a computer implemented method, apparatus, and computer program code for managing garbage collection in a data processing system.
2. Description of the Related Art
Garbage collection is a form of automatic memory management. A garbage collector or other process attempts to reclaim memory used by objects in the memory that will never be accessed or modified by an application or other process.
Garbage collection frees a programmer from having to worry about releasing objects that are no longer needed when writing applications. Further, garbage collection also may aid programmers in their efforts to make programs more stable because garbage collection may prevent various runtime errors that could occur. Examples of errors that may occur include, for example, dangling pointer bugs and double free bugs.
A dangling pointer bug may occur when a piece of memory is freed while pointers are still pointing to the memory and one of the pointers is used. A double free bug may occur when a region of memory is free and an attempt is made by a program to free that region of memory. Also, memory leaks that occur when a program fails to free memory that is no longer accessed also may be reduced and/or eliminated through garbage collection.
Garbage collection may be used in various environments including in a Java Virtual Machine (JVM). Garbage collection also may be available with other environments including, for example, C and C++.